<template>
    <div>
        <p style="font-weight: bold" class="interfaceHead"><i
                class="el-icon-s-promotion"></i>终审</p>
        <el-divider></el-divider>
        <el-table
                border
                :data="finalTable"
                style="width: 100%">
            <el-table-column
                    prop="id"
                    label="序号"
                    align="center"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="name"
                    label="姓名"
                    align="center"
                    width="160">
            </el-table-column>
            <el-table-column
                    prop="address"
                    label="地址"
                    align="center"
                    width="130">
            </el-table-column>
            <el-table-column
                    prop="check_result"
                    label="审核状态"
                    align="center">
            </el-table-column>
            <el-table-column
                    label="操作"
                    align="center">
                <template slot-scope="scope">
                    <el-button
                            size="mini"
                            @click="handleEdit(scope.$index, scope.row)">
                        编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-dialog
                :visible.sync="dialogFormVisible"
                width="60%">
            <el-card class="box-card" style="width: 70%;margin:auto">
                <div slot="header" class="clearfix">
                    <span>审核信息</span>
                </div>
                <div>单位名称：<el-tag>{{message.companyName}}</el-tag></div>
                <div>⾏政区划：<el-tag>{{message.address}}</el-tag></div>
                <div>职⼯⼈数：<el-tag>{{message.payroll}}</el-tag></div>
                <div>营业⾯积：<el-tag>{{message.area}}</el-tag>平⽅⽶</div>
                <div>
                    营业执照：
                    <br>
                    <img style="width: 180px; height: 250px" :src="this.$store.state.baseApi+message.trade" alt="">
                </div>
                <div>
                    现场照⽚：
                    <br>
                    <img style="width: 180px; height: 250px" :src="this.$store.state.baseApi+message.photo_link" alt="">
                </div>
            </el-card>
            <el-form ref="form" :model="form" style="margin-top:20px">
                <el-form-item label="检查结果">
                    <el-select v-model="form.checkResult"
                               placeholder="请选择">
                        <el-option
                                v-for="item in result"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div>
                <el-button class="buttonLeft" @click="submitIn" type="primary">通过</el-button>
                <el-button class="buttonRight" @click="submitOut" type="primary">不通过</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        name: "AuditorFinal",
        data() {
            return {
                finalTable: [],
                message:'',
                dialogFormVisible:false,
                form: {
                    checkResult: '',
                },
                result: [{
                    value: '合格',
                    label: '合格'
                }, {
                    value: '不合格',
                    label: '不合格'
                }],
                checkResult: [],
            }
        },
        mounted() {
            this.initFinaltable();
        },
        methods:{
            initFinaltable(){
                this.getRequest('/check/showZ').then(resp=>{
                    if(resp){
                        console.log(resp);
                        this.finalTable = resp.data.data;
                    }
                })
            },
            handleEdit(index,row){
                this.getRequest('/check/showzhu/'+row.id).then(resp=>{
                    if(resp){
                        console.log(resp);
                        this.dialogFormVisible = true;
                        this.message = resp.data.data;
                        console.log(this.message)
                    }
                })
            },
            submitIn(){
                this.postRequest('/check/insert/'+this.message.id+'/'+this.form.checkResult).then(resp=>{
                    if(resp){
                        this.dialogFormVisible = false;
                        this.initFinaltable();
                        this.postRequest('/cert/issue/'+this.message.companyName)
                    }
                })
            },
            submitOut(){
                this.postRequest('/check/insert/'+this.message.id+'/'+this.form.checkResult).then(resp=>{
                    if(resp){
                        this.dialogFormVisible = false;
                    }
                })
            }
        }
    }
</script>
<style scoped>
</style>